﻿using JWT.Algorithms;
using JWT.Serializers;
using JWT;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web;
using System.Web.Http;
using System.Web.Routing;
using MVC_Project.Bll.Systems;

namespace MVC_Project.Api.Areas.Systems
{
    [ApiAuthorize]
    public class MenusController : ApiController
    {

        MenusBll bll = new MenusBll();

        // GET: api/Menus
        public List<Models.Systems.Menus> Get()
        {
            //获取JWT 中验证后保存的数据
            var auth = Request.GetRouteData().Values["auth"] as AuthInfo;

            var menus = bll.GetMenusByRid(auth.RolesID);


            List<Models.Systems.Menus> list = new List<Models.Systems.Menus>();
            foreach (var menu in menus)
            {
                list.Add(new Models.Systems.Menus()
                {
                    menuID=menu.menuID,
                    menuName=menu.menuName,
                    vueUrl = menu.vueUrl,
                    parentID=menu.parentID,
                    icon = menu.icon
                });
            }

            return list;
        }

        // GET: api/Menus/5
        public string Get(int id)
        {
            return "value";
        }

        // POST: api/Menus
        public void Post([FromBody]string value)
        {
        }

        // PUT: api/Menus/5
        public void Put(int id, [FromBody]string value)
        {
        }

        // DELETE: api/Menus/5
        public void Delete(int id)
        {
        }


    }
}
